package com.nut.spp.service.impl;

import com.nut.spp.common.Result;
import com.nut.spp.entity.GoodsCompose;
import com.nut.spp.mapper.GoodsComposeMapper;
import com.nut.spp.service.GoodsComposeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

@Service
@Slf4j
public class GoodsComposeServiceImpl implements GoodsComposeService {

    @Autowired
    private GoodsComposeMapper goodsComposeMapper;

    @Override
    public Result<List<GoodsCompose>> selectByGoodsId(Integer goodsId) {
        List<GoodsCompose> list = goodsComposeMapper.selectByGoodsId(goodsId);
        return Result.ok(list);
    }

    @Override
    public Result<GoodsCompose> getById(Serializable id) {
        GoodsCompose goodsSpec = goodsComposeMapper.selectById(id);
        return Result.ok(goodsSpec);
    }

    @Override
    public Result add(GoodsCompose goodsSpec) {
        goodsComposeMapper.insert(goodsSpec);
        return Result.ok();
    }

    @Override
    public Result updateById(GoodsCompose goodsSpec) {
        goodsComposeMapper.updateById(goodsSpec);
        return Result.ok();
    }

    @Override
    public Result deleteByIds(Set<Integer> ids) {
        for (Integer id : ids) {
            goodsComposeMapper.deleteById(id);
        }
        return Result.ok();
    }
}